package com.cupk.carManageMaster.common.enums;
/**
 * @Software: IntelliJ IDEA
 * @Project: car-manage-master
 * @File: ErrorEnum.java
 * @Author: 箬玉
 * @Description: 错误枚举类
 * @Date: 2023/6/11 14:35
 */

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.ToString;

/**
 * @ClassName: ErrorEnum
 * @Author: 箬玉
 * @Description: 错误枚举类
 * @Date: 2023/6/11 14:35
 */
@Getter
@AllArgsConstructor
@ToString
public enum ErrorEnum {
    SUCCESS(0, "成功"),
    ERROR(-1, "服务器内部错误"),
    MYSQL_SERVER_ERROR(4001, "MySQL服务器异常"),
    OLD_PASSWORD_ERROR(4002, "旧密码错误"),
    CAR_TYPE_ERROR(4003, "车型有误"),
    SQL_EMPTY_ERROR(4004, "数据库为空");


    private final Integer code;
    private final String message;

    public static ErrorEnum getErrorEnum(Integer code) {
        ErrorEnum[] values = values();
        for (ErrorEnum value : values) {
            if (value.getCode().equals(code)) {
                return value;
            }
        }
        return ERROR;
    }
}
